Collect user interactions as events in your ecommerce store.
search-insights
library for you from jsDelivr.
You don’t need to install it or set it up yourself.
If you’re using a Content Security Policy to protect your site and you want to let InstantSearch load search-insights
for you, make sure to add https://cdn.jsdelivr.net
in your list of trusted sources for JavaScript.
search-insights
, you can add it to your project:
search-insights
when it detects it on the page.
search-insights
library to your project and make it globally available as window.aa
userToken
for sending events to the Insights API and for search requestsqueryID
parameter in the search responseinsights
option:
User action | Method name | Automatically collected? |
---|---|---|
User clicks search result | clickedObjectIDsAfterSearch | Yes |
User adds product to shopping cart | addedToCartObjectIDsAfterSearch | No |
User clicks categories/filters | clickedFilters | Yes |
User views search results | viewedObjectIDs | Yes |
User action | Method name | Automatically collected? |
---|---|---|
User clicks product | clickedObjectIDsAfterSearch | Yes |
User adds product to shopping cart | addedToCartObjectIDsAfterSearch | No |
User views category page | viewedObjectIDs | Yes |
User action | Method name | Automatically collected? |
---|---|---|
User adds product to cart | addedToCartObjectIDsAfterSearch | No |
User views product | viewedObjectIDs | No |
User action | Event | Automatically collected? |
---|---|---|
User buys product | purchasedObjectIDsAfterSearch | No |
conversion
event with the addToCart
subtype.
5.45
or '5.45'
).
To prevent floating-point math issues, use strings, especially if you’re performing calculations.windows.aa
object is the API client for the Insights API and is globally available
if you enabled automatic events collection.
The queryID
parameter is used by Algolia to relate the event to a prior search or browse event.
For add-to-cart events not related to a search query, for example, after a user clicks on a
‘Recommended for you’ or ‘Buy again’ carousel on the home page:
conversion
event with the purchase
subtype.
5.45
or '5.45'
).
To prevent floating-point math issues, use strings, especially if you’re performing calculations.sendEvent
function to send conversion events from your InstantSearch app.
click
events, setting custom conversion
events doesn’t prevent the custom click
event from being sent.hits
and infiniteHits
widgets expose a sendEvent
function.
Use it to send click
events when users interact with your search results.
click
event with the eventName
“Product Added to Favorites”click
event with the eventName
“Product Clicked” (through event propagation)Event.stopPropagation
in your event handler.
click
event that you defined, it doesn’t send the default click
event.
In the following example, when clicking the Add to favorites button, only the “Product Added to Favorites” event is sent.
authenticatedUserToken
parameter.